<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="UC_style.css">
<style>
.div_main1{	
	background:white;
	
	width:80%;
	/*border-style:ridge;
	border-color:RGBA(255,255,255,0.3);*/
	margin-left:10%;
	margin-right:10%;
}
.text1{
	height:22px;
	width:280px;
}
.table1{
	width:100%;
	border:0;
}
td{
	border:none;
	padding:15px 10px;
}

.td1{
	width:100px;
	height:22px;
	border:2px red;
}
.dv1{
	width:400px;
	float:left;
	height:22px;
	
}
.dv2{
	width:120px;
	float:left;
	height:22px;
}
.dv3{
	width:280px;
	float:left;
	height:22px;
}
.dv4{
	width:1000px;
	float:left;
	height:22px;
}
.button_Select{
		background-color:RGB(23,28,33);
    	border-width: 1px;
    	color: white;
    	padding: 5px 10px;
    	width: 100px;
   	 	text-align: center;
    	font-size: 16px;
    	border-radius: 12px;
	}
.button_Select:hover {
    background-color:RGB(38,169,226);
}
.button_file{
		background-color:RGB(64,158,255);
    	border-width: 1px;
    	color: white;
    	width: 22px;
    	height:22px;
   	 	text-align: center;
    	font-size: 18px;
    	margin-top:2px;
}
.button_file:hover {
    background-color:RGB(54,148,245);
}
</style>
</head>
<body>
<%
	String userid=request.getParameter("id");//取得传递过来的用户参数，用于查询和删除
	Connection conn=null;
	String sql="select * from car_info where car_id='"+userid+"'";
	try{
		Class.forName("org.h2.Driver");//加载驱动
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
		return;
	}
	try {
		conn = DriverManager.getConnection("jdbc:h2:d:/CompanyCar/temp/mydbtest", "sa", "");
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		if(rs!=null && rs.next()){//执行完sql语句后，rs指向第一条结果的前面，所以必须执行一次next()操作
			System.out.println("right");
		}
		else
		{	
			System.out.println("null");
		}
%>	
	<div class="main" style="background-color:white " >
		
		<div id="header2">
			<img src="img/首页.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
			首页 > 车辆管理 > 档案管理 > 车辆档案录入
		</div><br/>
		<div class="div_main1">
		<%String editURL="C-JDBC-Car_Details_edit.jsp?action=2&id="+rs.getInt("car_id"); %>
		<form action=<%=editURL %> method="post" ><!--enctype="multipart/form-data"  -->
			<table  class="table1">
				<tr >
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车辆名称：</div>
							<div class="dv3"><input type="text" name="car_name" class="text1" value=<%= rs.getString("car_name") %> ></div>
						</div>
				
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车辆类别：</div>
							<div class="dv3"><input type="text" name="car_type" class="text1" value=<%= rs.getString("car_type") %> ></div>
						</div>
					</td>				
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车牌号：</div>
							<div class="dv3"><input type="text" name="license_plate" class="text1" value=<%= rs.getString("license_plate") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车辆排量：</div>
							<div class="dv3"><input type="text" name="displacement" class="text1" value=<%= rs.getFloat("displacement") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">开始使用日期：</div>
							<div class="dv3"><input type="text" name="start_date" class="text1" value=<%= rs.getDate("start_date") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">管理部门：</div>
							<div class="dv3"><input type="text" name="management_department" class="text1" value=<%= rs.getString("management_department") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">责任人：</div>
							<div class="dv3"><input type="text" name="responsible_person" class="text1" value=<%= rs.getString("responsible_person") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">登记人：</div>
							<div class="dv3"><input type="text" name="register_person" class="text1" value=<%= rs.getString("register_person") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">资产编号：</div>
							<div class="dv3"><input type="text" name="asset_number" class="text1" value=<%= rs.getString("asset_number") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">购置日期：</div>
							<div class="dv3"><input type="text" name="purchase_date" class="text1" value=<%= rs.getDate("purchase_date") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">价值：</div>
							<div class="dv3"><input type="text" name="value" class="text1" value=<%= rs.getFloat("value") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车架号：</div>
							<div class="dv3"><input type="text" name="frame_number" class="text1" value=<%= rs.getString("frame_number") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">车辆用途：</div>
							<div class="dv3"><input type="text" name="car_usage" class="text1" value=<%= rs.getString("car_usage") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">使用状况：</div>
							<div class="dv3"><input type="text" name="usage_status" class="text1" value=<%= rs.getString("usage_status") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">使用部门：</div>
							<div class="dv3"><input type="text" name="usage_department" class="text1" value=<%= rs.getString("usage_department") %> ></div>
						</div>
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">使用人：</div>
							<div class="dv3"><input type="text" name="usage_person" class="text1" value=<%= rs.getString("usage_person") %> ></div>
						</div>
					</td>
				</tr>
				<tr>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">入账日期：</div>
							<div class="dv3"><input type="text" name="entry_date" class="text1" value=<%= rs.getDate("entry_date") %> ></div>
						</div>
						
					</td>
					<td width="40%" align="left" >
						<div class="dv1">
							<div class="dv2">资料附件：</div>
							<div class="dv3" style="width:260px">
								<%
								Blob blob = rs.getBlob("data_attachment");
								String value = blob != null ? blob.toString() : "无";
								%>
								<input type="text" class="text1" name="lookfile" id="lookfile" value=<%= value %>  readonly>
							</div>
							<div class="dv3" style="width:20px">
								<input type="button" class="button_file" value="+" onclick="path.click()" >
								<input type="file"  name="data_attachment" id="path" style="display:none" onchange="lookfile.value=this.value">
							</div>						
						</div>
						
					</td>
				</tr>			
				<%
				rs.close();
				stmt.close();
				//关闭表达式对象				
				conn.close();

				} catch (SQLException e) {
					e.printStackTrace();
				} finally {
				//防止数据库未正常关闭
					try {
						if (conn != null && (!conn.isClosed())) {
							conn.close();
					}
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}
				%>
				<tr>
					<td width="25%" align="center" style="padding:45px 5px;">
					
						<input type="submit" class="button_Select" value="确认修改" >
				</tr>			
			</table>
			</form>
		</div>
		
		
	</div>
</body>
</html>